package com.sinoyd.itszyw.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.sinoyd.itszyw.Model.IssueInfo;
import com.sinoyd.itszyw.R;

import java.util.List;

/**
 * @author: Sinoyd  --------->作者
 * @description: --------->描述
 * @projectName: ITSZYW  ---------> 项目名称
 * @date: 2017-03-10 ---------> 创建日期
 * @time: 15:39       ---------> 创建时间
 */
public class SelectAdapter extends BaseAdapter{

    private List arrayList;
    private LayoutInflater mLayoutInflater;
    private Context mContext;

    public SelectAdapter(Context context, List list){
        this.mContext = context;
        this.arrayList = list;
        this.mLayoutInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return arrayList == null ? 0 : arrayList.size();
    }

    @Override
    public Object getItem(int i) {
        return arrayList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        View cell = null;
        if (view == null)
        {
                cell = mLayoutInflater.inflate(R.layout.listview_pop,null);

        }else {
            cell = view;
        }

        TextView textView = (TextView) cell.findViewById(R.id.tv_pop);
        if (arrayList.get(i) instanceof IssueInfo){
            IssueInfo issueInfo = (IssueInfo)arrayList.get(i);
            textView.setText(issueInfo.issueName);

        }else {
            textView.setText(arrayList.get(i).toString());
        }
//        if(mCurrentPos == i){
//            textView.setBackgroundColor(mContext.getResources().getColor(R.color.color_blue_light));
//        } else {
//            textView.setBackgroundColor(Color.TRANSPARENT);
//        }



        return cell;
    }
}
